// PinyinDictTranslator.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "QQ2Bing.h"
#include <vector>
#include <cassert>

int _tmain(int argc, _TCHAR* argv[])
{
	using namespace CodeMood;
	// shared_ptr supports upcasting
	shared_ptr<Translator> sptran = make_shared<QQ2Bing>("D:\\QQPinyin_2013_4_8.txt");

	// auto and decltype make life better
	auto sptran2 = make_shared<QQ2Bing>("D:\\QQPinyin_2013_4_8.txt", "D:\\BingPinyin.txt");

	vector<decltype(sptran)> vecsptran;

	// Implicit copy
	vecsptran.push_back(sptran);
	vecsptran.push_back(sptran2);

	// Works fine
	sptran2->translate();

	QQ2Bing translator("D:\\QQPinyin_2013_4_8.txt");
	// Copy control is easy when shared_ptr is used
	{
		// Copy and destroy
		QQ2Bing translator2(translator);
	}

	// Make sure that spif is valid
	assert(translator.get_spif()->is_open());

	shared_ptr<ifstream> spif = translator.get_spif();

	//Works fine
	//translator.translate();

	QQ2Bing q2b;
	q2b = translator;
	// Synthesized operator= also works fine
	q2b.translate();

	cout << "Translation Success!\nEnjoy coding~" << endl;

	return 0;
}

